<template>
    <div class="content">
        <ul>
            <li v-if="store.articleData.length === 0">
                <h1>暂无文章</h1>
            </li>
            <li v-for="item in store.articleData" :key="item.article_id"
                @click="listClick(item.article_id, item.views)">
                <el-card style="
                    width: 100%;
                    margin: 10px 0;
                    cursor: pointer;
                  ">
                    <div style="display: flex;">
                        <img :src="store.imageUrl + item.cover" style="height: 50px; margin-right: 20px;" />
                        <div>
                            <div style="display: flex; align-items: flex-end;">
                                <span class="title" style="margin-right: 20px;">{{ item.title }}</span>
                                <img src="../images/lll.svg" style="height: 25px; display: inline;">
                                <span class="view" style="margin-right: 20px;">{{ item.views }}</span>
                                <img src="../images/good.svg" style="height: 20px; display: inline;">
                                <span class=" good">{{ item.good_count }}</span>
                            </div>

                            <div class="intro">{{ item.intro }}</div>
                        </div>
                    </div>
                </el-card>
            </li>
            <el-pagination background layout="prev, pager, next, total" :total="store.count" :page-size="store.pagesize"
                :current-page="store.page" class="mt-4" style="top: 350px; left: 700px; position: absolute"
                @current-change="store.changePage" />
        </ul>
    </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'
import useStore from '../store.ts'

const store = useStore()

const listClick = (article_id: number, views: number) => {
    let newViews = views + 1
    store.addViewsData(article_id, newViews)
    store.getArticleData()
    store.toDetail(article_id)
}
onMounted(() => {
    store.getArticleData()
})




</script>

<style>
.content {
    height: 498px;
    width: 1280px;
    padding: 20px;
    overflow-y: hidden;
    /* 移除滚动条 */
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
    border-radius: 12px;
    /* 确保四个角都是圆角 */
    position: relative;
    /* 为分页定位做准备 */

    ul {
        width: 100%;
        height: calc(100% - 60px);
        /* 为分页留出空间 */
        padding: 0;
        margin: 0;
        list-style: none;
        overflow: hidden;
        /* 防止内容溢出 */
    }

    li {
        margin-bottom: 16px;
        transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);

        &:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
        }

        h1 {
            text-align: center;
            color: #909399;
            font-weight: normal;
            padding: 50px 0;
            font-size: 18px;
        }
    }

    .el-card {
        border-radius: 12px !important;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08) !important;
        transition: all 0.3s ease;
        border: none !important;
        background: rgba(255, 255, 255, 0.9) !important;
        backdrop-filter: blur(5px);
        overflow: hidden;
        margin-right: 2px;
        /* 防止阴影被裁剪 */

        &:hover {
            box-shadow: 0 8px 25px rgba(64, 158, 255, 0.15) !important;
            background: rgba(255, 255, 255, 0.95) !important;
        }

        >div {
            padding: 18px;
            background: transparent !important;
        }

        img[src*="cover"] {
            height: 100px !important;
            width: 150px !important;
            object-fit: cover;
            border-radius: 8px;
            margin-right: 25px !important;
            box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s;
        }

        &:hover img[src*="cover"] {
            transform: scale(1.03);
        }

        .title {
            font-size: 19px;
            font-weight: 600;
            color: #2c3e50;
            margin-right: 25px !important;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 650px;
            letter-spacing: 0.3px;
        }

        .view,
        .good {
            font-size: 15px;
            color: #7f8c8d;
            margin-right: 25px !important;
            display: inline-flex;
            align-items: center;
            font-weight: 500;
        }

        img[src*=".svg"] {
            height: 18px !important;
            width: 18px !important;
            margin-right: 8px !important;
            opacity: 0.9;
            transition: all 0.2s;
        }

        &:hover img[src*=".svg"] {
            opacity: 1;
            transform: translateY(-1px);
        }

        .intro {
            margin-top: 12px;
            color: #57606f;
            font-size: 15px;
            line-height: 1.6;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
            text-overflow: ellipsis;
        }
    }

    .el-pagination {
        position: absolute !important;
        bottom: 10px !important;
        /* 调整到底部 */
        left: 50% !important;
        transform: translateX(-50%) !important;
        padding: 0px 25px !important;
        background: rgba(255, 255, 255, 0.95) !important;
        border-radius: 30px !important;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1) !important;
        width: auto !important;
        height: 100px;
        min-width: 500px !important;
        display: flex !important;
        justify-content: center !important;
        backdrop-filter: blur(5px);
        border: 1px solid rgba(220, 223, 230, 0.5);
        margin-top: 20px;
        /* 增加与内容的间距 */

        .btn-prev,
        .btn-next {
            padding: 0 18px !important;
            font-size: 15px !important;
            color: #606266 !important;
            font-weight: 500;

            &:hover {
                color: #409eff !important;
                transform: scale(1.1);
            }
        }

        .el-pager {
            display: flex !important;
            margin: 0 12px !important;

            li {
                margin: 0 6px !important;
                min-width: 38px !important;
                height: 38px !important;
                line-height: 38px !important;
                border-radius: 19px !important;
                font-size: 15px !important;
                background: rgba(245, 247, 250, 0.8) !important;
                border: 1px solid rgba(220, 223, 230, 0.7) !important;
                color: #2c3e50 !important;
                font-weight: 500;
                transition: all 0.2s;

                &:hover {
                    color: #409eff !important;
                    border-color: #a0cfff !important;
                    background: rgba(236, 245, 255, 0.8) !important;
                    transform: translateY(-2px);
                }

                &.active {
                    background: linear-gradient(135deg, #409eff 0%, #64b5f6 100%) !important;
                    color: white !important;
                    border-color: #409eff !important;
                    font-weight: 600;
                    box-shadow: 0 4px 8px rgba(64, 158, 255, 0.3);
                }

                &.more {
                    background: transparent !important;
                    border: none !important;
                }
            }
        }

        .el-pagination__total {
            margin: 0 18px !important;
            font-size: 15px !important;
            color: #7f8c8d !important;
        }
    }
}
</style>